home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / nt_dsp1.lzh / NT_DSP1.MSA / FFT / FFTR2B.ASM < prev    next >
Assembly Source File  |  1990-01-17  |  4KB  |  117 lines

  1. ;
  2. ; This program originally available on the Motorola DSP bulletin board.
  3. ; It is provided under a DISCLAMER OF WARRANTY available from
  4. ; Motorola DSP Operation, 6501 Wm. Cannon Drive W., Austin, Tx., 78735.
  5. ; Radix 2, In-Place, Decimation-In-Time FFT (faster than fftr2a.asm)
  6. ; Last Update 02 Oct 86   Version 1.1
  7. ;
  8. fftr2b  macro   points,data,coef
  9. fftr2b  ident   1,1
  10. ;
  11. ; Radix 2 Decimation in Time In-Place Fast Fourier Transform Routine
  12. ;
  13. ;    Complex input and output data
  14. ;        Real data in X memory
  15. ;        Imaginary data in Y memory
  16. ;    Normally ordered input data
  17. ;    Bit reversed output data
  18. ;       Coefficient lookup table
  19. ;        -Cosine values in X memory
  20. ;        -Sine values in Y memory
  21. ;
  22. ; Macro Call - fftr2b   points,data,coef
  23. ;
  24. ;       points     number of points (4-32768, power of 2)
  25. ;       data       start of data buffer
  26. ;       coef       start of sine/cosine table
  27. ;
  28. ; Alters Data ALU Registers
  29. ;       x1      x0      y1      y0
  30. ;       a2      a1      a0      a
  31. ;       b2      b1      b0      b
  32. ;
  33. ; Alters Address Registers
  34. ;       r0      n0      m0
  35. ;       r1      n1      m1
  36. ;               n2
  37. ;
  38. ;       r4      n4      m4
  39. ;       r5      n5      m5
  40. ;       r6      n6      m6
  41. ;
  42. ; Alters Program Control Registers
  43. ;       pc      sr
  44. ;
  45. ; Uses 6 locations on System Stack
  46. ;
  47. ; Latest Revision - September 30, 1986
  48. ;
  49.         move    #points/2,n0    ;initialize butterflies per group
  50.         move    #1,n2           ;initialize groups per pass
  51.         move    #points/4,n6    ;initialize coefficient offset
  52.         move    #-1,m0          ;initialize address modifiers
  53.         move    m0,m1           ;for linear addressing
  54.         move    m0,m4
  55.         move    m0,m5
  56.         move    #0,m6           ;initialize coefficient address modifier
  57.                                 ;for reverse carry (bit reversed) addressing
  58. ;
  59. ; Do all FFT passes but last pass
  60. ;
  61.         do      #@cvi(@log(points)/@log(2)-0.5),_end_pass
  62.         move    #data,r0                ;initialize A input pointer
  63.         move    r0,r4                   ;initialize A output pointer
  64.         lua     (r0)+n0,r1      ;initialize B input pointer
  65.         move    #coef,r6        ;initialize C input pointer
  66.         lua     (r1)-,r5        ;initialize B output pointer
  67.         move    n0,n1           ;initialize pointer offsets
  68.         move    n0,n4
  69.         move    n0,n5
  70.  
  71.         do      n2,_end_grp
  72.         move    x:(r1),x1       y:(r6),y0       ;lookup -sine value
  73.         move    x:(r5),a        y:(r0),b
  74.         move    x:(r6)+n6,x0            ;lookup -cosine value
  75.  
  76.  
  77.         do      n0,_end_bfy     ;Radix 3 DIT butterfly kernel with constant
  78.         mac     x1,y0,b                         y:(r1)+,y1  ;twiddle factor
  79.         macr    -x0,y1,b        a,x:(r5)+       y:(r0),a
  80.         subl    b,a             x:(r0),b        b,y:(r4)
  81.         mac     -x1,x0,b        x:(r0)+,a       a,y:(r5)
  82.         macr    -y1,y0,b        x:(r1),x1
  83.         subl    b,a             b,x:(r4)+       y:(r0),b
  84. _end_bfy
  85.         move    a,x:(r5)+n5     y:(r1)+n1,y1    ;dummy load of x1 and y1
  86.         move    x:(r0)+n0,x1    y:(r4)+n4,y1
  87. _end_grp
  88.         move    n0,b1
  89.         lsr     b       n2,a1   ;divide butterflies per group by two
  90.         lsl     a       b1,n0   ;multiply groups per pass by two
  91.         move            a1,n2
  92. _end_pass
  93. ;
  94. ; Do last FFT pass
  95. ;
  96.         move    n1,n0           ;correct pointer offset for last pass
  97.         move    #data,r0        ;initialize A input pointer
  98.         move    r0,r4           ;initialize A output pointer
  99.         lua     (r0)+,r1        ;initialize B input pointer
  100.         move    #coef,r6        ;initialize C input pointer
  101.         lua     (r1)-n1,r5      ;initialize B output pointer
  102.         move    x:(r1),x1       y:(r6),y0
  103.         move    x:(r5),a        y:(r0),b
  104.  
  105.         do      n2,_lastpass    ;Radix 2 DIT butterfly kernel with one
  106.         mac     x1,y0,b x:(r6)+n6,x0    y:(r1)+n1,y1    ;butterfly per group
  107.         macr    -x0,y1,b        a,x:(r5)+n5     y:(r0),a
  108.         subl    b,a     x:(r0),b        b,y:(r4)
  109.         mac     -x1,x0,b        x:(r0)+n0,a     a,y:(r5)
  110.         macr    -y1,y0,b        x:(r1),x1       y:(r6),y0
  111.         subl    b,a             b,x:(r4)+n4     y:(r0),b
  112. _lastpass
  113.         move    a,x:(r5)+n5
  114.         endm
  115.